Operators in ST
Operators execute operations and provide functionality, such as addition. The operators combine the operands to form expressions.
Possible operators
No. |
Description of operation: symbol |
Examples |
Precedence |
Corresponding |
---|---|---|---|---|
1 |
parentheses:
|
|
12 (highest) |
|
2 |
call of function or call of a method, if there is a return value:
|
|
11 |
|
3 |
dereference
Details: see under "Declaration of reference variables (incl. assignments to them)" |
|
10 |
|
4 |
negation:
|
|
9 |
|
5 |
unary plus:
|
|
9 |
|
6 |
complement:
|
|
9 |
|
7 |
exponentiation:
|
|
8 |
|
8 |
multiply:
|
|
7 |
|
9 |
divide:
|
|
7 |
|
10 |
modulo:
|
|
7 |
|
11 |
add:
|
|
6 |
|
12 |
subtract:
|
|
6 |
|
13 |
comparison:
|
|
5 |
|
14 |
equality:
|
|
4 |
|
15 |
inequality:
|
A <> B |
4 |
|
16a |
Boolean AND:
|
|
3 |
|
16b |
Boolean AND:
|
|
3 |
|
17 |
Boolean exclusive OR:
|
|
2 |
|
18 |
Boolean OR:
|
|
1 (lowest) |
Notes:
-
Operators can be →overloaded.
-
Only the following operators can be applied to the datatypes
STRING
andCHAR
:=, <>, <, >, <=, >=
Deviation from IEC-standard The operators for comparison |
-
Only the equality operator = and the inequality operator
<>
can be applied to declared variables based on an →interface andNULL
.
Comparing variables based on an interface or of such a variable with NULL |
---|
|
-
The column "Corresponding standard block" informs which operator returns the same results as the corresponding standard block. The condition is that the operator works with the same data as the standard block. Example: Expression
x+y
for the addition has a behavior identical to this call of theADD
block:ADD(x,y)
Observe: If the block description contains the warnung "No check of invalid connections", this warnung also applies to the corresponding ST-operator. This warning looks like this (or it is simular to it):
No check of invalid connections For some blocks, invalid connections are not checked by Neuron Power Engineer. Therefore, enter code in your application to detect invalid connections (e.g. See "Standard blocks for the application" for information what the consequences of an invalid connection might be. |
Deviation from IEC-standard The "no check of invalid connections" is a deviation from the →IEC-standard that demands an error handling, if the result of the block exceeds the range of values for the output data type. This deviation also applies to the corresponding ST-operator. |
-
On other errors (e.g. in case of a division by
0
), the value0
is returned but the outputENO
of the embracing →POU is not set to valueFALSE
(or an equivalent). -
Mind the correct combination of the →literals/→variables for multiplication, division, addition and subtraction, if the operation is done for literals/variables of data type
TIME
. Other combinations will be highlighted as faulty.
operation: symbol |
data type for operand and result |
example |
behavior identical to this block |
---|---|---|---|
multiply: |
|
|
|
divide: |
|
|
|
add: |
|
|
|
subtract: |
|
T#4s - T#3s |
|